#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,T,ans;
int a[200010];
int main(){
freopen("color.in","r",stdin);
freopen("color.out","w",stdout);
cin>>T;
while(T--){
ans=0;
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++){
    if(a[i]==a[j]){ans+=a[i];break;}
}
cout<<ans<<endl;
}
return 0;
}
